package com.cn.wanxi.servlet.back.product;

import com.cn.wanxi.model.ResultModel;
import com.cn.wanxi.service.IproductService;
import com.cn.wanxi.service.impl.ProductServiceImpl;
import net.sf.json.JSONArray;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
@WebServlet("/ProductFindAll")
public class ProductFindAllServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("UTF-8");
        resp.setCharacterEncoding("UTF-8");

        IproductService iproductService =new ProductServiceImpl();
        ResultModel resultModel=iproductService.findAll();

        JSONArray jsonArray = JSONArray.fromObject(resultModel);
        resp.getWriter().println(jsonArray);
    }
}
